﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ISerives;
using Model;
using EFEntity;

namespace HR.Controllers
{
    public class ClientController : Controller
    {
        private readonly Iconfig_public_charSerives ipcs;

        public ClientController(Iconfig_public_charSerives ipcs)
        {
            this.ipcs = ipcs;
        }
        public IActionResult Index()
        {
            return View();
        }
        #region 公共属性设置
        /// <summary>
        /// 公共属性设置查询
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> Public_char()
        {
           ViewData.Model=await ipcs.Select();
            return View();
        }
        /// <summary>
        /// 公共属性设置删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<IActionResult> Del(int id)
        {
            if (await ipcs.Del(id)>0)
            {
                return RedirectToAction("Public_char");
            }
            else
            {
                return View();
            }
        }
        /// <summary>
        /// 公共属性设置添加get
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Public_char_add()
        {
            return View();
        }
        /// <summary>
        /// 公共属性设置添加post
        /// </summary>
        /// <param name="cpc"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Public_char_add(Econfig_public_char cpc)
        {
            if (await ipcs.Add(cpc)>0)
            {
                return RedirectToAction("Public_char");
            }
            else
            {
                return View(cpc);
            }
        }
        #endregion

        #region 薪酬项目设置
        /// <summary>
        /// 薪酬项目设置查询
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> salary_item()
        {
          ViewData.Model=await ipcs.SelectShow("薪酬设置");
            return View();
        }
        /// <summary>
        /// 薪酬项目设置删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<IActionResult> XC_Del(int id)
        {
            if (await ipcs.Del(id)>0)
            {
                return RedirectToAction("salary_item");
            }
            else
            {
                return View();
            }
           
        }
        /// <summary>
        /// 薪酬项目设置添加Get
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public  IActionResult salary_item_register()
        {
            return  View();
        }
        /// <summary>
        /// 薪酬项目设置Post
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> salary_item_register(Econfig_public_char epc)
        {
          
            if (ModelState.IsValid)
            {
            if (await ipcs.Add(epc)>0)
            {
                return RedirectToAction("salary_item");
            }
            else
            {
                return View(epc);
            }
            }
            else
            {
                return View(epc);
            }
        }
        #endregion
    }
}